function snap(value,grid_space)
{
    return Math.floor(value / grid_space) * grid_space;
}